#include "GUI.h"

#include "main.h"
#include "Lcd_Driver.h"
#include "font.h"

//��ILI93xx����������ΪGBR��ʽ��������д���ʱ��ΪRGB��ʽ��
//ͨ���ú���ת��
//c:GBR��ʽ����ɫֵ
//����ֵ��RGB��ʽ����ɫֵ
uint16_t LCD_BGR2RGB(uint16_t c)
{
  uint16_t  r,g,b,rgb;   
  b=(c>>0)&0x1f;
  g=(c>>5)&0x3f;
  r=(c>>11)&0x1f;	 
  rgb=(b<<11)+(g<<5)+(r<<0);		 
  return(rgb);

}




void Gui_Circle(uint16_t X,uint16_t Y,uint16_t R,uint16_t fc) 
{//Bresenham�㷨 
    unsigned short  a,b; 
    int c; 
    a=0; 
    b=R; 
    c=3-2*R; 
    while (a<b) 
    { 
        Gui_DrawPoint(X+a,Y+b,fc);     //        7 
        Gui_DrawPoint(X-a,Y+b,fc);     //        6 
        Gui_DrawPoint(X+a,Y-b,fc);     //        2 
        Gui_DrawPoint(X-a,Y-b,fc);     //        3 
        Gui_DrawPoint(X+b,Y+a,fc);     //        8 
        Gui_DrawPoint(X-b,Y+a,fc);     //        5 
        Gui_DrawPoint(X+b,Y-a,fc);     //        1 
        Gui_DrawPoint(X-b,Y-a,fc);     //        4 

        if(c<0) c=c+4*a+6; 
        else 
        { 
            c=c+4*(a-b)+10; 
            b-=1; 
        } 
       a+=1; 
    } 
    if (a==b) 
    { 
        Gui_DrawPoint(X+a,Y+b,fc); 
        Gui_DrawPoint(X+a,Y+b,fc); 
        Gui_DrawPoint(X+a,Y-b,fc); 
        Gui_DrawPoint(X-a,Y-b,fc); 
        Gui_DrawPoint(X+b,Y+a,fc); 
        Gui_DrawPoint(X-b,Y+a,fc); 
        Gui_DrawPoint(X+b,Y-a,fc); 
        Gui_DrawPoint(X-b,Y-a,fc); 
    } 
	
} 
//���ߺ�����ʹ��Bresenham �����㷨
void Gui_DrawLine(uint16_t x0, uint16_t y0,uint16_t x1, uint16_t y1,uint16_t Color)   
{
int dx,             // difference in x's
    dy,             // difference in y's
    dx2,            // dx,dy * 2
    dy2, 
    x_inc,          // amount in pixel space to move during drawing
    y_inc,          // amount in pixel space to move during drawing
    error,          // the discriminant i.e. error i.e. decision variable
    index;          // used for looping	


	Lcd_SetXY(x0,y0);
	dx = x1-x0;//����x����
	dy = y1-y0;//����y����

	if (dx>=0)
	{
		x_inc = 1;
	}
	else
	{
		x_inc = -1;
		dx    = -dx;  
	} 
	
	if (dy>=0)
	{
		y_inc = 1;
	} 
	else
	{
		y_inc = -1;
		dy    = -dy; 
	} 

	dx2 = dx << 1;
	dy2 = dy << 1;

	if (dx > dy)//x�������y���룬��ôÿ��x����ֻ��һ���㣬ÿ��y���������ɸ���
	{//���ߵĵ�������x���룬��x���������
		// initialize error term
		error = dy2 - dx; 

		// draw the line
		for (index=0; index <= dx; index++)//Ҫ���ĵ������ᳬ��x����
		{
			//����
			Gui_DrawPoint(x0,y0,Color);
			
			// test if error has overflowed
			if (error >= 0) //�Ƿ���Ҫ����y����ֵ
			{
				error-=dx2;

				// move to next line
				y0+=y_inc;//����y����ֵ
			} // end if error overflowed

			// adjust the error term
			error+=dy2;

			// move to the next pixel
			x0+=x_inc;//x����ֵÿ�λ���󶼵���1
		} // end for
	} // end if |slope| <= 1
	else//y�����x�ᣬ��ÿ��y����ֻ��һ���㣬x�����ɸ���
	{//��y��Ϊ��������
		// initialize error term
		error = dx2 - dy; 

		// draw the line
		for (index=0; index <= dy; index++)
		{
			// set the pixel
			Gui_DrawPoint(x0,y0,Color);

			// test if error overflowed
			if (error >= 0)
			{
				error-=dy2;

				// move to next line
				x0+=x_inc;
			} // end if error overflowed

			// adjust the error term
			error+=dx2;

			// move to the next pixel
			y0+=y_inc;
		} // end for
	} // end else |slope| > 1
}



void Gui_box(uint16_t x, uint16_t y, uint16_t w, uint16_t h,uint16_t bc)
{
	Gui_DrawLine(x,y,x+w,y,0xEF7D);
	Gui_DrawLine(x+w-1,y+1,x+w-1,y+1+h,0x2965);
	Gui_DrawLine(x,y+h,x+w,y+h,0x2965);
	Gui_DrawLine(x,y,x,y+h,0xEF7D);
    Gui_DrawLine(x+1,y+1,x+1+w-2,y+1+h-2,bc);
}
void Gui_box2(uint16_t x,uint16_t y,uint16_t w,uint16_t h, uint8_t mode)
{
	if (mode==0)	{
		Gui_DrawLine(x,y,x+w,y,0xEF7D);
		Gui_DrawLine(x+w-1,y+1,x+w-1,y+1+h,0x2965);
		Gui_DrawLine(x,y+h,x+w,y+h,0x2965);
		Gui_DrawLine(x,y,x,y+h,0xEF7D);
		}
	if (mode==1)	{
		Gui_DrawLine(x,y,x+w,y,0x2965);
		Gui_DrawLine(x+w-1,y+1,x+w-1,y+1+h,0xEF7D);
		Gui_DrawLine(x,y+h,x+w,y+h,0xEF7D);
		Gui_DrawLine(x,y,x,y+h,0x2965);
	}
	if (mode==2)	{
		Gui_DrawLine(x,y,x+w,y,0xffff);
		Gui_DrawLine(x+w-1,y+1,x+w-1,y+1+h,0xffff);
		Gui_DrawLine(x,y+h,x+w,y+h,0xffff);
		Gui_DrawLine(x,y,x,y+h,0xffff);
	}
}


/**************************************************************************************
��������: ����Ļ��ʾһ͹��İ�ť��
��    ��: uint16_t x1,y1,x2,y2 ��ť�����ϽǺ����½�����
��    ��: ��
**************************************************************************************/
void DisplayButtonDown(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2)
{
	Gui_DrawLine(x1,  y1,  x2,y1, GRAY2);  //H
	Gui_DrawLine(x1+1,y1+1,x2,y1+1, GRAY1);  //H
	Gui_DrawLine(x1,  y1,  x1,y2, GRAY2);  //V
	Gui_DrawLine(x1+1,y1+1,x1+1,y2, GRAY1);  //V
	Gui_DrawLine(x1,  y2,  x2,y2, WHITE);  //H
	Gui_DrawLine(x2,  y1,  x2,y2, WHITE);  //V
}

/**************************************************************************************
��������: ����Ļ��ʾһ���µİ�ť��
��    ��: uint16_t x1,y1,x2,y2 ��ť�����ϽǺ����½�����
��    ��: ��
**************************************************************************************/
void DisplayButtonUp(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2)
{
	Gui_DrawLine(x1,  y1,  x2,y1, WHITE); //H
	Gui_DrawLine(x1,  y1,  x1,y2, WHITE); //V
	
	Gui_DrawLine(x1+1,y2-1,x2,y2-1, GRAY1);  //H
	Gui_DrawLine(x1,  y2,  x2,y2, GRAY2);  //H
	Gui_DrawLine(x2-1,y1+1,x2-1,y2, GRAY1);  //V
    Gui_DrawLine(x2  ,y1  ,x2,y2, GRAY2); //V
}


void Gui_DrawFont_GBK16(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *s)
{
	unsigned char i,j;
	unsigned short k,x0;
	x0=x;

	while(*s) 
	{	
		if((*s) < 128) 
		{
			k=*s;
			if (k==13) 
			{
				x=x0;
				y+=16;
			}
			else 
			{
				if (k>32) k-=32; else k=0;
	
			    for(i=0;i<16;i++)
				for(j=0;j<8;j++) 
					{
				    	if(asc16[k*16+i]&(0x80>>j))	Gui_DrawPoint(x+j,y+i,fc);
						else 
						{
							if (fc!=bc) Gui_DrawPoint(x+j,y+i,bc);
						}
					}
				x+=8;
			}
			s++;
		}
			
		else 
		{
		

			for (k=0;k<hz16_num;k++) 
			{
			  if ((hz16[k].Index[0]==*(s))&&(hz16[k].Index[1]==*(s+1)))
			  { 
				    for(i=0;i<16;i++)
				    {
						for(j=0;j<8;j++) 
							{
						    	if(hz16[k].Msk[i*2]&(0x80>>j))	Gui_DrawPoint(x+j,y+i,fc);
								else {
									if (fc!=bc) Gui_DrawPoint(x+j,y+i,bc);
								}
							}
						for(j=0;j<8;j++) 
							{
						    	if(hz16[k].Msk[i*2+1]&(0x80>>j))	Gui_DrawPoint(x+j+8,y+i,fc);
								else 
								{
									if (fc!=bc) Gui_DrawPoint(x+j+8,y+i,bc);
								}
							}
				    }
				}
			  }
			s+=2;x+=16;
		} 
		
	}
}

void Gui_DrawFont_GBK24(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *s)
{
	unsigned char i,j;
	unsigned short k;

	while(*s) 
	{
		if( *s < 0x80 ) 
		{
			k=*s;
			if (k>32) k-=32; else k=0;

		    for(i=0;i<16;i++)
			for(j=0;j<8;j++) 
				{
			    	if(asc16[k*16+i]&(0x80>>j))	
					Gui_DrawPoint(x+j,y+i,fc);
					else 
					{
						if (fc!=bc) Gui_DrawPoint(x+j,y+i,bc);
					}
				}
			s++;x+=8;
		}
		else 
		{

			for (k=0;k<hz24_num;k++) 
			{
			  if ((hz24[k].Index[0]==*(s))&&(hz24[k].Index[1]==*(s+1)))
			  { 
				    for(i=0;i<24;i++)
				    {
						for(j=0;j<8;j++) 
							{
						    	if(hz24[k].Msk[i*3]&(0x80>>j))
								Gui_DrawPoint(x+j,y+i,fc);
								else 
								{
									if (fc!=bc) Gui_DrawPoint(x+j,y+i,bc);
								}
							}
						for(j=0;j<8;j++) 
							{
						    	if(hz24[k].Msk[i*3+1]&(0x80>>j))	Gui_DrawPoint(x+j+8,y+i,fc);
								else {
									if (fc!=bc) Gui_DrawPoint(x+j+8,y+i,bc);
								}
							}
						for(j=0;j<8;j++) 
							{
						    	if(hz24[k].Msk[i*3+2]&(0x80>>j))	
								Gui_DrawPoint(x+j+16,y+i,fc);
								else 
								{
									if (fc!=bc) Gui_DrawPoint(x+j+16,y+i,bc);
								}
							}
				    }
			  }
			}
			s+=2;x+=24;
		}
	}
}
void Gui_DrawFont_Num32(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint16_t num)
{
	unsigned char i,j,k,c;
	//lcd_text_any(x+94+i*42,y+34,32,32,0x7E8,0x0,sz32,knum[i]);
//	w=w/8;

    for(i=0;i<32;i++)
	{
		for(j=0;j<4;j++) 
		{
			c=*(sz32+num*32*4+i*4+j);
			for (k=0;k<8;k++)	
			{
	
		    	if(c&(0x80>>k))	Gui_DrawPoint(x+j*8+k,y+i,fc);
				else {
					if (fc!=bc) Gui_DrawPoint(x+j*8+k,y+i,bc);
				}
			}
		}
	}
}

void Gui_DrawFont_ASCII3264_Bold(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *s)
{
	// Scale 8x16 ASCII to 32x64 (4x both axes) with bold dilation
	uint16_t x0 = x;

	while (*s)
	{
		uint8_t ch = *s;

		if (ch == '\r') { x = x0; s++; continue; }
		if (ch == '\n') { x = x0; y += 64; s++; continue; }

		if (ch < 128)
		{
			uint8_t k = ch;
			if (k > 32) k -= 32; else k = 0;

			uint16_t y_base = y;
			for (uint8_t src_row = 0; src_row < 16; src_row++)
			{
				uint8_t row_bits = asc16[k * 16 + src_row];
				uint8_t row_bits_bold = row_bits | (row_bits >> 1) | (row_bits >> 2) | (row_bits >> 3);

				// Repeat each source row four times to reach 64px height
				for (int rep = 0; rep < 4; rep++)
				{
					for (uint8_t bit = 0; bit < 8; bit++)
					{
						uint16_t px = x + (uint16_t)bit * 4;
						uint16_t is_set = (row_bits_bold & (0x80 >> bit)) ? 1 : 0;
						if (!is_set && fc == bc) continue;
						if (is_set)
						{
							Gui_DrawPoint(px + 0, y, fc);
							Gui_DrawPoint(px + 1, y, fc);
							Gui_DrawPoint(px + 2, y, fc);
							Gui_DrawPoint(px + 3, y, fc);
						}
						else if (fc != bc)
						{
							Gui_DrawPoint(px + 0, y, bc);
							Gui_DrawPoint(px + 1, y, bc);
							Gui_DrawPoint(px + 2, y, bc);
							Gui_DrawPoint(px + 3, y, bc);
						}
					}
					y += 1;
				}
			}

			s++; x += 32; y = y_base;
		}
		else
		{
			s += 2; x += 32;
		}
	}
}

void Gui_DrawFont_ASCII3264_Smooth(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *s)
{
	// 32x64 upscale with 3x3 Gaussian blur + 4x4 ordered dithering for smoother edges
	static const uint8_t gauss3x3[9] = {1,2,1,2,4,2,1,2,1}; // sum = 16
	static const uint8_t bayer4x4[16] = {
		0,  8,  2, 10,
		12, 4, 14,  6,
		3, 11,  1,  9,
		15, 7, 13,  5
	};
	uint16_t x0 = x;

	while (*s)
	{
		uint8_t ch = *s;

		if (ch == '\r') { x = x0; s++; continue; }
		if (ch == '\n') { x = x0; y += 64; s++; continue; }

		if (ch < 128)
		{
			uint8_t k = ch;
			if (k > 32) k -= 32; else k = 0;

			uint16_t y_base = y;
			for (uint8_t dy = 0; dy < 64; dy++)
			{
				uint8_t sy = dy >> 2; // 0..15
				for (uint8_t dx = 0; dx < 32; dx++)
				{
					uint8_t sx = dx >> 2; // 0..7

					// 3x3 weighted sum around (sx, sy) in source bitmap
					uint16_t acc = 0;
					uint8_t idx = 0;
					for (int8_t oy = -1; oy <= 1; oy++)
					{
						int8_t ry = (int8_t)sy + oy;
						uint8_t row_bits = 0;
						if (ry >= 0 && ry < 16) row_bits = asc16[k * 16 + (uint8_t)ry];
						for (int8_t ox = -1; ox <= 1; ox++, idx++)
						{
							int8_t rx = (int8_t)sx + ox;
							uint8_t bit_on = 0;
							if (rx >= 0 && rx < 8)
							{
								if (row_bits & (0x80 >> (uint8_t)rx)) bit_on = 1;
							}
							acc += (uint16_t)bit_on * gauss3x3[idx];
						}
					}

					// Ordered dithering threshold 0..15
					uint8_t th = bayer4x4[((dy & 3) << 2) | (dx & 3)];
					// acc in [0,16]; compare against threshold to decide
					if (acc > th)
					{
						Gui_DrawPoint(x + dx, y + dy, fc);
					}
					else if (fc != bc)
					{
						Gui_DrawPoint(x + dx, y + dy, bc);
					}
				}
			}

			s++; x += 32; y = y_base;
		}
		else
		{
			s += 2; x += 32;
		}
	}
}


void Gui_DrawFont_ASCII1625(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *s)
{
    // Render ASCII at 16x25 by scaling existing 8x16 font (2x width, 16->25 rows using Bresenham distribution)
    uint16_t x0 = x;

    while (*s)
    {
        uint8_t ch = *s;

        if (ch == '\r') { x = x0; s++; continue; }
        if (ch == '\n') { x = x0; y += 25; s++; continue; }

        if (ch < 128)
        {
            uint8_t k = ch;
            if (k > 32) k -= 32; else k = 0;

            // Bresenham-style row replication: map 16 source rows to 25 output rows
            uint16_t y_base = y;
            int error_acc = 0;
            for (uint8_t src_row = 0; src_row < 16; src_row++)
            {
                uint8_t row_bits = asc16[k * 16 + src_row];

                // Determine how many times to replicate this row (1 or 2)
                int repeats = 1;
                error_acc += 25; // numerator
                while (error_acc >= 16) { repeats++; error_acc -= 16; }
                if (repeats > 2) repeats = 2; // safety cap

                for (int rep = 0; rep < repeats; rep++)
                {
                    // Draw one expanded row at current Y
                    for (uint8_t bit = 0; bit < 8; bit++)
                    {
                        uint16_t px = x + (bit << 1);
                        uint16_t color = (row_bits & (0x80 >> bit)) ? fc : bc;
                        if (color == bc && fc == bc) continue;
                        // 2x horizontally
                        if (row_bits & (0x80 >> bit))
                        {
                            Gui_DrawPoint(px + 0, y, fc);
                            Gui_DrawPoint(px + 1, y, fc);
                        }
                        else if (fc != bc)
                        {
                            Gui_DrawPoint(px + 0, y, bc);
                            Gui_DrawPoint(px + 1, y, bc);
                        }
                    }
                    y += 1;
                }
            }

            // Reset baseline for next character
            s++; x += 16; y = y_base;
        }
        else
        {
            // Non-ASCII: skip or render as space width
            s += 2; x += 16;
        }
    }
}

void Gui_DrawFont_ASCII1625_Bold(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *s)
{
    // Bold variant: horizontal dilation (row_bits | (row_bits >> 1)) then scale to 16x25
    uint16_t x0 = x;

    while (*s)
    {
        uint8_t ch = *s;

        if (ch == '\r') { x = x0; s++; continue; }
        if (ch == '\n') { x = x0; y += 25; s++; continue; }

        if (ch < 128)
        {
            uint8_t k = ch;
            if (k > 32) k -= 32; else k = 0;

            uint16_t y_base = y;
            int error_acc = 0;
            for (uint8_t src_row = 0; src_row < 16; src_row++)
            {
                uint8_t row_bits = asc16[k * 16 + src_row];
                // Horizontal thicken by one pixel to the right without changing glyph width
                uint8_t row_bits_bold = row_bits | (row_bits >> 1);

                int repeats = 1;
                error_acc += 25;
                while (error_acc >= 16) { repeats++; error_acc -= 16; }
                if (repeats > 2) repeats = 2;

                for (int rep = 0; rep < repeats; rep++)
                {
                    for (uint8_t bit = 0; bit < 8; bit++)
                    {
                        uint16_t px = x + (bit << 1);
                        uint16_t is_set = (row_bits_bold & (0x80 >> bit)) ? 1 : 0;
                        if (!is_set && fc == bc) continue;
                        if (is_set)
                        {
                            Gui_DrawPoint(px + 0, y, fc);
                            Gui_DrawPoint(px + 1, y, fc);
                        }
                        else if (fc != bc)
                        {
                            Gui_DrawPoint(px + 0, y, bc);
                            Gui_DrawPoint(px + 1, y, bc);
                        }
                    }
                    y += 1;
                }
            }

            s++; x += 16; y = y_base;
        }
        else
        {
            s += 2; x += 16;
        }
    }
}

void Gui_DrawFont_ASCII1632_Bold(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *s)
{
    // Scale 8x16 ASCII to 16x32 (2x both axes) with a simple bold dilation
    uint16_t x0 = x;

    while (*s)
    {
        uint8_t ch = *s;

        if (ch == '\r') { x = x0; s++; continue; }
        if (ch == '\n') { x = x0; y += 32; s++; continue; }

        if (ch < 128)
        {
            uint8_t k = ch;
            if (k > 32) k -= 32; else k = 0;

            uint16_t y_base = y;
            for (uint8_t src_row = 0; src_row < 16; src_row++)
            {
                uint8_t row_bits = asc16[k * 16 + src_row];
                uint8_t row_bits_bold = row_bits | (row_bits >> 1);

                // Repeat each source row twice to reach 32px height
                for (int rep = 0; rep < 2; rep++)
                {
                    for (uint8_t bit = 0; bit < 8; bit++)
                    {
                        uint16_t px = x + (bit << 1);
                        uint16_t is_set = (row_bits_bold & (0x80 >> bit)) ? 1 : 0;
                        if (!is_set && fc == bc) continue;
                        if (is_set)
                        {
                            Gui_DrawPoint(px + 0, y, fc);
                            Gui_DrawPoint(px + 1, y, fc);
                        }
                        else if (fc != bc)
                        {
                            Gui_DrawPoint(px + 0, y, bc);
                            Gui_DrawPoint(px + 1, y, bc);
                        }
                    }
                    y += 1;
                }
            }

            s++; x += 16; y = y_base;
        }
        else
        {
            s += 2; x += 16;
        }
    }
}

void Gui_DrawFont_ASCII0810(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *s)
{
    // Downscale 8x16 ASCII to 8x10 by row sampling (integer rounding)
    uint16_t x0 = x;

    while (*s)
    {
        uint8_t ch = *s;

        if (ch == '\r') { x = x0; s++; continue; }
        if (ch == '\n') { x = x0; y += 10; s++; continue; }

        if (ch < 128)
        {
            uint8_t k = ch;
            if (k > 32) k -= 32; else k = 0;

            // Map 10 destination rows to 16 source rows with rounding
            for (uint8_t dst_row = 0; dst_row < 10; dst_row++)
            {
                // Integer round: nearest source row for this destination row
                uint8_t src_row = (uint8_t)((dst_row * 16 + 5) / 10);
                if (src_row > 15) src_row = 15;
                uint8_t row_bits = asc16[k * 16 + src_row];

                for (uint8_t bit = 0; bit < 8; bit++)
                {
                    uint16_t is_set = (row_bits & (0x80 >> bit)) ? 1 : 0;
                    if (!is_set && fc == bc) continue;
                    if (is_set)
                    {
                        Gui_DrawPoint(x + bit, y + dst_row, fc);
                    }
                    else if (fc != bc)
                    {
                        Gui_DrawPoint(x + bit, y + dst_row, bc);
                    }
                }
            }

            s++; x += 8;
        }
        else
        {
            s += 2; x += 8;
        }
    }
}

void Gui_DrawFont_ASCII2448_Bold(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *s)
{
	// Scale 8x16 ASCII to 24x48 (3x both axes) with bold dilation
	uint16_t x0 = x;

	while (*s)
	{
		uint8_t ch = *s;

		if (ch == '\r') { x = x0; s++; continue; }
		if (ch == '\n') { x = x0; y += 48; s++; continue; }

		if (ch < 128)
		{
			uint8_t k = ch;
			if (k > 32) k -= 32; else k = 0;

			uint16_t y_base = y;
			for (uint8_t src_row = 0; src_row < 16; src_row++)
			{
				uint8_t row_bits = asc16[k * 16 + src_row];
				uint8_t row_bits_bold = row_bits | (row_bits >> 1) | (row_bits >> 2);

				// Repeat each source row three times to reach 48px height
				for (int rep = 0; rep < 3; rep++)
				{
					for (uint8_t bit = 0; bit < 8; bit++)
					{
						uint16_t px = x + (uint16_t)bit * 3;
						uint16_t is_set = (row_bits_bold & (0x80 >> bit)) ? 1 : 0;
						if (!is_set && fc == bc) continue;
						if (is_set)
						{
							Gui_DrawPoint(px + 0, y, fc);
							Gui_DrawPoint(px + 1, y, fc);
							Gui_DrawPoint(px + 2, y, fc);
						}
						else if (fc != bc)
						{
							Gui_DrawPoint(px + 0, y, bc);
							Gui_DrawPoint(px + 1, y, bc);
							Gui_DrawPoint(px + 2, y, bc);
						}
					}
					y += 1;
				}
			}

			s++; x += 24; y = y_base;
		}
		else
		{
			s += 2; x += 24;
		}
	}
}